export const crudOptions = (vm) => {
	return {
		pageOptions: {
			compact: true,
		},
		options: {
			tableType: "vxe-table",
			rowKey: true, // 必须设置，true or false
			rowId: "id",
			height: "100%", // 表格高度100%, 使用toolbar必须设置
			highlightCurrentRow: false,
		},
		selectionRow: {
			align: "center",
			width: 60,
		},
		rowHandle: {
			width: 370,
			fixed: "right",
			view: {
				show: false,
				disabled() {
					return !vm.hasPermissions("Retrieve");
				},
			},
			edit: {
				thin: true,
				show: false,
				text: "编辑",
				disabled() {
					return !vm.hasPermissions("Update");
				},
			},
			remove: {
				thin: true,
				show: false,
				text: "删除",
				disabled() {
					return !vm.hasPermissions("Delete");
				},
			},
			custom: [
				{
					text: "用户拉黑",
					size: "small",
					type: "danger",
					show(index, row) {
						if (row.is_black == 0) {
							return false;
						} else {
							return true;
						}
					},
					emit: "userBlack",
				},
				{
					size: "small",
					text: "取消拉黑",
					type: "warning",
					show(index, row) {
						if (row.is_black == 1) {
							return false;
						} else {
							return true;
						}
					},
					emit: "is_userBlack",
				},
				{
					size: "small",
					text: "打标签",
					type: "primary",
					emit: "setLabel",
				},
				{
					size: "small",
					text: "修改备注",
					type: "success",
					emit: "setRemake",
				},
			],
		},
		indexRow: {
			// 或者直接传true,不显示title，不居中
			title: "序号",
			align: "center",
			width: 100,
		},

		viewOptions: {
			componentType: "form",
		},
		formOptions: {
			defaultSpan: 24, // 默认的表单 span
			width: "35%",
			saveRemind: true,
		},
		/* formOptions: {
			defaultSpan: 12, // 默认的表单 span
		}, */
		columns: [
			{
				title: "关键词",
				key: "search",
				show: false,
				disabled: true,
				search: {
					disabled: false,
				},
				form: {
					disabled: true,
					component: {
						placeholder: "请输入关键词",
						props: {
							clearable: true,
						},
					},
				},
				view: {
					// 查看对话框组件的单独配置
					disabled: true,
				},
			},
			{
				title: "ID",
				key: "id",
				show: false,
				width: 90,
				form: {
					disabled: true,
				},
			},

			{
				title: "粉丝昵称",
				key: "name",
				minWidth: 160,
				search: true,
				type: "input",
				form: {
					component: {
						props: {
							clearable: true,
						},
						placeholder: "请输入粉丝昵称",
					},
				},
			},

			{
				title: "头像",
				key: "head_portrait",
				rowSlot: true,
				minWidth: 190,
				type: "avatar-cropper",
			},
			{
				title: "openid",
				key: "open_id",
				minWidth: 190,
				type: "input",
				search: true,
				form: {
					component: {
						props: {
							clearable: true,
						},
						placeholder: "请输入openid",
					},
				},
			},
			{
				title: "union_id",
				key: "union_id",
				minWidth: 190,
				type: "input",
				search: true,
				form: {
					component: {
						props: {
							clearable: true,
						},
						placeholder: "请输入union_id",
					},
				},
			},
			{
				title: "是否订阅公众号",
				key: "subscribe",
				minWidth: 130,
				search: true,
				type: "select",
				dict: {
					data: [
						{ value: 0, label: "未订阅" },
						{ value: 1, label: "订阅" },
					],
				},
				form: {
					component: {
						props: {
							clearable: true,
						},
						placeholder: "请选择是否订阅公众号",
					},
				},
			},
			{
				title: "语言",
				key: "language",
				width: 90,
				type: "input",
				form: {
					component: {
						placeholder: "请输入语言",
					},
				},
			},

			{
				title: "标签名称",
				key: "fan_tags_list",
				minWidth: 310,
				type: "input",
				rowSlot: true,
				search: false,
				form: {
					component: {
						placeholder: "请输入标签id",
					},
				},
			},
			{
				title: "标签名称",
				key: "fan_tags_name",
				width: 90,
				search: false,
				disabled: true,
				type: "input",
				form: {
					component: {
						props: {
							clearable: true,
						},
						placeholder: "请输入标签名称",
					},
				},
			},
			{
				title: "是否拉黑",
				key: "is_black",
				width: 90,
				type: "select",
				search: true,
				dict: {
					data: [
						{
							value: 0,
							color: "danger",
							label: "是",
						},
						{
							value: 1,
							label: "否",
						},
					],
				},
				form: {
					component: {
						placeholder: "请选择是否拉黑",
					},
				},
			},
			{
				title: "关注渠道",
				key: "subscribe_scene",
				minWidth: 170,
				search: true,
				type: "input",
				form: {
					component: {
						props: {
							clearable: true,
						},
						placeholder: "请输入关注渠道",
					},
				},
			},
			{
				title: "备注",
				key: "remark",
				minWidth: 190,
				type: "input",
				form: {
					component: {
						placeholder: "请输入备注",
					},
				},
			},
			{
				title: "关注时间",
				key: "subscribe_time",
				minWidth: 190,
				type: "input",
				fixed: "right",
				form: {
					component: {
						placeholder: "请输入关注时间",
					},
				},
			},
		],
	};
};
